package org.stbland.test.gillesjava;

import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;

public class PinDrawText extends PinDraw {

	private Writer out;

	public PinDrawText(Writer out) {
		super();
		this.out = out;
	}

	@Override
	public void draw(List<Pin> pinList) {
		int size = pinList.size();

		Pin pin;
		for (int i = 0; i < size; i++) {
			pin = pinList.get(i);
			drawPin(pin);
		}
		
		/*
		Iterator<Pin> iterator = pinList.iterator();
		while ( iterator.hasNext())
		{
			pin = iterator.next();
			
		}
		*/
	}

	private void drawPin(Pin pin) {

		switch (pin.getType()) {
		case INPUT:
			println("<<<");
			break;
		case OUTPUT:
			println(">>>");
			break;
		case UNUSED:
			println("<->");
			break;
		}

	}

	private void println(String str) {
		try {
			out.write(str + "\n");
		} catch (IOException e) {

		}
	}
}
